﻿using System;
using System.Collections.Generic;
using System.Data.Entity.Migrations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace JobbJakt
{
  public partial class Merits
    {
      public static List<Merits> GetMerits(string userName)
      {
          var query = JobbJaktDB.Meritses
              .Where(n => n.UserName == userName).ToList();
          return query;
      }

      public static int UpdateMerit(Merits merit)
      {
          JobbJaktDB.Meritses.AddOrUpdate(merit);
          return JobbJaktDB.Save();
      }
      /// <summary>
      /// 
      /// </summary>
      /// <param name="merit"></param>
      /// <returns></returns>
      public static int DeleteMerit(Merits merit)
      {
          JobbJaktDB.Meritses.Remove(merit);
          return JobbJaktDB.Save();
      }
      /// <summary>
      /// 
      /// </summary>
      /// <param name="merits"></param>
      /// <returns></returns>
      public static int InsertMerit(Merits merits)
      {
          JobbJaktDB.Meritses.Add(merits);
          return JobbJaktDB.Save();
      }
      public override string ToString()
      {
          return string.Format("Merit ID:{0} Merit:{1} Nivå:{2} Användare Namn:{3}", MeritID, Merit, SkillLevel,
              UserName);
      }
    }
}
